<!---->
<template>
    <div class="page_memberSpecialInfo">
        <common-header :title="'特殊人群信息编辑'">
            <span slot="overwrite-left"></span>
        </common-header>
        <div class="btn-save" @click="savememberInfo">保存</div>
        <div class="pages-main" style="height: calc( 100vh - 45px)">
            <div class="item-info item-speacial">
                <group>
                    <x-switch title="刑释人员" v-model="interpretationinterpretation"></x-switch>
                </group>
                <group>
                    <x-switch title="精神病人员" v-model="mentaldisease"></x-switch>
                </group>
                <div v-show="mentaldisease">
                    <div class="item-item">
                        <div class="item-item every-block-padding item-inline">
                            <span class="item-itemLabel">危险程度</span>
                            <select class="translateBlock" v-model="dangerleave"
                                    style="text-align-last: right;;width: 7.2rem;font-size:0.38rem;">
                                <option :value="'低'">低</option>
                                <option :value="'中'">中</option>
                                <option :value="'高'">高</option>
                            </select>
                        </div>
                    </div>
                    <div class="item-item">
                        <x-input title="精神病类型" v-model="mentaltype"
                                 placeholder="请输入精神病类型">
                        </x-input>
                    </div>
                    <div class="item-item">
                        <x-input title="患病名称" v-model="mentalname"
                                 placeholder="请输入患病名称">
                        </x-input>
                    </div>
                    <group>
                        <x-switch title="是否接受过治疗" v-model="hadtreat"></x-switch>
                    </group>
                    <group>
                        <x-switch title="目前是否正在接受治疗" v-model="istreating"></x-switch>
                    </group>
                    <div class="item-item">
                        <datetime :min-year="1900" title="发病时间" placeholder="请选择发病时间" v-model="mentalbegintime1"></datetime>
                    </div>
                </div>
                <group>
                    <x-switch title="吸毒人员" v-model="isdrug"></x-switch>
                </group>
                <group>
                    <x-switch title="危险品从业人员" v-model="ishazardousperson"></x-switch>
                </group>
                <group>
                    <x-switch title="重点上访人员" v-model="isimportvisitors"></x-switch>
                </group>
            </div>
        </div>
    </div>
</template>

<script>
    import {XSwitch, Group, Cell, XInput, Datetime} from 'vux'
    import resident from '../../services/resident'

    export default {
        name: "memberSpecialInfo",
        components: {
            XSwitch,
            Group,
            Cell,
            XInput,
            Datetime
        },
        data() {
            return {
                id: this.$route.query.id,
                interpretationinterpretation: Number(this.$route.query.interpretationinterpretation) ? true : false,
                mentaldisease: Number(this.$route.query.mentaldisease) ? true : false,
                dangerleave: this.$route.query.dangerleave ? this.$route.query.dangerleave :'低',
                mentaltype: this.$route.query.mentaltype? this.$route.query.mentaltype :'',
                mentalname: this.$route.query.mentalname? this.$route.query.mentalname   :'',
                hadtreat: Number(this.$route.query.hadtreat) ? true : false,
                istreating: Number(this.$route.query.istreating) ? true : false,
                mentalbegintime1: this.$route.query.mentalbegintime,
                isdrug: Number(this.$route.query.isdrug) ? true : false,
                ishazardousperson: Number(this.$route.query.ishazardousperson) ? true : false,
                isimportvisitors: Number(this.$route.query.isimportvisitors) ? true : false,
            }
        },

        created() {

        },
        watch: {},
        methods: {
            //  保存成员信息
            savememberInfo() {
                let param = {
                    id: this.id,
                    dangerleave: this.dangerleave,
                    hadtreat: this.hadtreat ? 1 : 0,
                    interpretationinterpretation: this.interpretationinterpretation ? 1 : 0,
                    isdrug: this.isdrug ? 1 : 0,
                    ishazardousperson: this.ishazardousperson ? 1 : 0,
                    isimportvisitors: this.isimportvisitors ? 1 : 0,
                    istreating: this.istreating ? 1 : 0,
                    mentaldisease: this.mentaldisease ? 1 : 0,
                    mentalbegintime: this.mentalbegintime1 ? this.mentalbegintime1 + ' ' + '00:00:00' : '',
                    mentalname: this.mentalname,
                    mentaltype: this.mentaltype,
                }
                let _param = this.$tools.invokeUAF('resident/updateDangerPopulationInfo', param)
                resident.updateDangerPopulationInfo(_param).then(res => {
                    let data = res.data.data;
                })
            },
        },
    };
</script>

<style lang="less" rel="stylesheet/less" type="text/less">
    .page_memberSpecialInfo {
        .item-speacial {
            .weui-cells {
                margin-top: 0 !important;
            }
            .weui-cell{
                padding: 10px 15px !important;
            }

            .weui-cells:after {
                border-bottom: 1px solid #f4f4f4 !important;
            }
        }
    }
</style>
